//
//  ZzscjlVC+UI.swift
//  Auscultation
//
//  Created by 来 on 2020/12/22.
//

import Foundation

extension ZzscjlVC: UITextViewDelegate {
    
    func initUI() {
        let top_view = UIImageView.init(image: #imageLiteral(resourceName: "beijing3@1.5x"))
        top_view.isUserInteractionEnabled = true
        view.addSubview(top_view)
        top_view.snp.makeConstraints { (make) in
            make.top.left.right.equalToSuperview()
            make.height.equalTo(UIDevice.lgf_NavBarH())
        }
        self.navTitle = "主诊医生筛查结论"
        self.lgf_NavigationBar.style.lgf_TitleColor = UIColor.white
        self.lgf_NavigationBar.lgf_Reload()
        
        scrollView = UIScrollView.lgf_Table("FFFFFF")
        if #available(iOS 11.0, *) {
            scrollView.contentInsetAdjustmentBehavior = .never
        } else {
            self.automaticallyAdjustsScrollViewInsets = false
        }
        view.addSubview(scrollView)
        scrollView.snp.makeConstraints { (make) in
            make.top.equalTo(top_view.snp.bottom)
            make.left.right.bottom.equalToSuperview()
        }
        
        ybqk = LGFLoginImageTitleView.init(nil, nil, left: 80, placeholder: "", text: "", true)
        scrollView.addSubview(ybqk)
        ybqk.snp.makeConstraints { (make) in
            make.width.equalToSuperview().offset(-30)
            make.centerX.equalToSuperview()
            make.top.equalToSuperview().offset(10)
            make.height.equalTo(44.lgf_H())
        }
        let ybqk_l = UILabel.init()
        ybqk_l.text = "样本情况"
        ybqk_l.textColor = UIColor.init(lgf_HexString: "222222")
        ybqk_l.font = UIFont.boldSystemFont(ofSize: 16)
        ybqk.addSubview(ybqk_l)
        ybqk_l.snp.makeConstraints { (make) in
            make.left.equalToSuperview()
            make.top.bottom.equalToSuperview()
        }
        
        let ybqk_x = UILabel.init()
        ybqk_x.text = "*"
        ybqk_x.textColor = UIColor.init(lgf_HexString: "CE4C4C")
        ybqk_x.font = UIFont.boldSystemFont(ofSize: 16)
        ybqk.addSubview(ybqk_x)
        ybqk_x.snp.makeConstraints { (make) in
            make.left.equalToSuperview().offset(-10)
            make.centerY.equalToSuperview().offset(2)
        }
        
        ybqk_s = LGFSegmentView.init()
        ybqk_s.layer.cornerRadius = 15
        ybqk.addSubview(ybqk_s)
        ybqk_s.snp.makeConstraints { (make) in
            make.right.equalToSuperview()
            make.centerY.equalToSuperview()
            make.height.equalTo(30)
            make.width.equalTo(180)
        }
        
        DispatchQueue.main.async {
            self.ybqk_s.setData(data: ["正常", "异常", "待确定"], font: UIFont.systemFont(ofSize: 14), selectColor: UIColor.init(lgf_HexString: "0F88F2"), unSelectColor: UIColor.init(lgf_HexString: "E0E6EB"), sTextColor: UIColor.white, unsTextColor: UIColor.white, dx: false)
        }
        
        
        bzxz = LGFLoginImageTitleView.init(nil, nil, left: 80, placeholder: "", text: "", true)
        bzxz.isHidden = true
        scrollView.addSubview(bzxz)
        bzxz.snp.makeConstraints { (make) in
            make.width.equalToSuperview().offset(-30)
            make.centerX.equalToSuperview()
            make.top.equalTo(ybqk.snp.bottom).offset(10)
            make.height.equalTo(0)
        }
        let bzxz_l = UILabel.init()
        bzxz_l.text = "病种选择"
        bzxz_l.textColor = UIColor.init(lgf_HexString: "222222")
        bzxz_l.font = UIFont.boldSystemFont(ofSize: 16)
        bzxz.addSubview(bzxz_l)
        bzxz_l.snp.makeConstraints { (make) in
            make.left.equalToSuperview()
            make.top.bottom.equalToSuperview()
        }
        
        let bzxz_x = UILabel.init()
        bzxz_x.text = "*"
        bzxz_x.textColor = UIColor.init(lgf_HexString: "CE4C4C")
        bzxz_x.font = UIFont.boldSystemFont(ofSize: 16)
        bzxz.addSubview(bzxz_x)
        bzxz_x.snp.makeConstraints { (make) in
            make.left.equalToSuperview().offset(-10)
            make.centerY.equalToSuperview().offset(2)
        }
        
        bzxz_s = LGFSegmentView.init()
        bzxz_s.layer.cornerRadius = 15
        bzxz.addSubview(bzxz_s)
        bzxz_s.snp.makeConstraints { (make) in
            make.right.equalToSuperview()
            make.centerY.equalToSuperview()
            make.height.equalTo(30)
            make.left.equalTo(bzxz_l.snp.right).offset(20)
        }
        
        DispatchQueue.main.async {
            self.bzxz_s.setData(data: ["VSD", "ASD", "PDA", "PS", "TOF"], font: UIFont.systemFont(ofSize: 14), selectColor: UIColor.init(lgf_HexString: "0F88F2"), unSelectColor: UIColor.init(lgf_HexString: "E0E6EB"), sTextColor: UIColor.white, unsTextColor: UIColor.white, dx: true)
        }
        
        let label3 = UILabel.init()
        label3.text = "备注"
        label3.textColor = UIColor.init(lgf_HexString: "222222")
        label3.font = UIFont.boldSystemFont(ofSize: 16)
        scrollView.addSubview(label3)
        label3.snp.makeConstraints { (make) in
            make.width.equalToSuperview().offset(-30)
            make.centerX.equalToSuperview()
            make.top.equalTo(bzxz.snp.bottom).offset(10)
            make.height.equalTo(44.lgf_H())
        }
        bz = UITextView.init()
        bz.delegate = self
        bz.font = UIFont.systemFont(ofSize: 16)
        bz.backgroundColor = UIColor.init(lgf_HexString: "F6F9FB")
        scrollView.addSubview(bz)
        bz.snp.makeConstraints { (make) in
            make.top.equalTo(label3.snp.bottom)
            make.width.equalToSuperview().offset(-30)
            make.centerX.equalToSuperview()
            make.height.equalTo(200)
        }
        bz_p = UILabel.init()
        bz_p.text = "请输入"
        bz_p.textColor = UIColor.init(lgf_HexString: "CFD4D9")
        scrollView.addSubview(bz_p)
        bz_p.snp.makeConstraints { (make) in
            make.top.equalTo(label3.snp.bottom).offset(7)
            make.left.equalToSuperview().offset(22)
        }
        
        let bc = UIButton.init(type: .custom)
        bc.backgroundColor = UIColor.init(lgf_HexString: EWEDarkMode.c_0F88F2)!
        bc.setTitle("保存", for: .normal)
        bc.setTitleColor(EWEDarkMode.white(), for: .normal)
        bc.titleLabel?.font = UIFont.systemFont(ofSize: 15)
        bc.layer.cornerRadius = 4
        bc.layer.masksToBounds = true
        bc.addTarget(self, action: #selector(ZzscjlVC.s_bc), for: .touchUpInside)
        view.addSubview(bc)
        bc.snp.makeConstraints { (make) in
            make.top.equalTo(bz.snp.bottom).offset(30)
            make.centerX.equalToSuperview()
            make.width.equalToSuperview().offset(-75)
            make.height.equalTo(50)
        }
    }
    
    func textViewDidChange(_ textView: UITextView) {
        bz_p.isHidden = textView.text.count > 0
    }
    
}

